package com.plian.system.service.im.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.plian.Tools.CollectionUtil;
import com.plian.system.entity.im.NegativeSupervise;
import com.plian.system.mapper.im.NegativeSuperviseMapper;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.service.im.NegativeSuperviseService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author lwb
 * @create 2023-02-08
 * @description
 */
@Service
public class NegativeSuperviseServiceImpl extends BaseServiceImpl <NegativeSuperviseMapper, NegativeSupervise> implements NegativeSuperviseService {

    @Override
    public boolean deleteByParentId(List<Long> ids) {
        LambdaQueryWrapper<NegativeSupervise> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(NegativeSupervise::getTypeId, ids);
        List<NegativeSupervise> list = list(queryWrapper);
        if (CollectionUtil.isNotEmpty(list)){
            return deleteLogic(list.stream().map(NegativeSupervise::getId).collect(Collectors.toList()));
        }
        return true;
    }
}
